package com.welkom.everydate.services.implementations;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.welkom.everydate.dao.AuthorityDao;
import com.welkom.everydate.dao.ResourceDao;
import com.welkom.everydate.domain.Authority;
import com.welkom.everydate.services.interfaces.ResourceService;
@Service
public class ResourceServiceImpl implements ResourceService {

	@Resource
	AuthorityDao authorityDao;
	@Resource
	ResourceDao resourceDao;
	public List<com.welkom.everydate.domain.Resource> getResourcesByAuthorityName(String authorityName) {
		// TODO Auto-generated method stub
		return null;
	}

	public List<com.welkom.everydate.domain.Resource> getResourcesByAuthorityId(long authorityId) {
		// TODO Auto-generated method stub
		Authority authority=authorityDao.getAuthorityById(authorityId);
		List<com.welkom.everydate.domain.Resource> resources=resourceDao.getResourcesByAuthorityId(authorityId);
		authority.setResources(resources);
		return authority.getResources();
	}

	@Override
	public void saveChangesToResource(
			com.welkom.everydate.domain.Resource resource) {
		// TODO Auto-generated method stub
		resourceDao.updateResource(resource);
		
	}

	@Override
	public void removeResource(long resourceId) {
		// TODO Auto-generated method stub
		resourceDao.removeResourceById(resourceId);
	}

	@Override
	public void addResource(com.welkom.everydate.domain.Resource resource) {
		// TODO Auto-generated method stub
		resourceDao.addResource(resource);
	}

	@Override
	public List<com.welkom.everydate.domain.Resource> getAllResources() {
		// TODO Auto-generated method stub
		return resourceDao.getAllResources();
	}

	@Override
	public void removeAuthorityResourceRelationsByAuthorityId(long authorityId) {
		// TODO Auto-generated method stub
		resourceDao.removeAuthorityResourceRelationsByAuthorityId(authorityId);
	}

	@Override
	public void addAuthorityResourceRelations(
			List<com.welkom.everydate.domain.Resource> resources,
			long authorityId) {
		// TODO Auto-generated method stub
		resourceDao.addAuthorityResourceRelations(resources, authorityId);
		
	}

	@Override
	public List<com.welkom.everydate.domain.Resource> getResourcesByAuthorityIds(List<Long> authorityIds) {
		// TODO Auto-generated method stub
		return resourceDao.getResourcesByAuthorityIds(authorityIds);
	}
	
	

}
